<?php
//header("Content-type: text/html; charset=utf-8");
include_once ('wx_access_token.php');

//创建菜单
function createMenu($data,$access_token){
//	print_r($access_token);print_r($data);exit;
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token);
	curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
	curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$tmpInfo = curl_exec($ch);
	if (curl_errno($ch)) {
	  return curl_error($ch);
	}
	curl_close($ch);
	return $tmpInfo;
}
$data = '{
    "button": [
        {
            "name": "公司介绍", 
            "sub_button": [
                {
                    "type": "click", 
                    "name": "关于我们", 
                    "key": "about_us"
                },
				{	
				   "type":"view",
				   "name":"基因秀", 
                   "url": "http://u.eqxiu.com/s/euHgNrxN"
				},
				{	
				   "type":"view",
				   "name":"新闻动态",
				   "url":"http://mp.weixin.qq.com/mp/homepage?__biz=MzA4MDcxMzAxMg==&hid=4&sn=1f140253bd89b0f0663b010b95ea5a08#wechat_redirect"
				},
				{	
				   "type":"click",
				   "name":"联系我们",
				   "key":"call_us"
				}
            ]
        },
		
		{
            "name": "产品中心", 
            "sub_button": [
           		{	
				   "type":"view",
				   "name":"抗体检索",
				   "url":"http://bl.weixinzjit.com/wxtest/dna_cms/product"
				},
				{
		          "type":"click",
				   "name":"CFDA注册产品",
				   "key":"pic"
		        },
                {
		          "type":"click",
				   "name":"基因检测",
				   "key":"picture"
		        }
            ]
        },
        {	
        	"type":"view",
            "name": "精彩回顾", 
			"url":"http://mp.weixin.qq.com/mp/homepage?__biz=MzA4MDcxMzAxMg==&hid=1&sn=5fa21b0ff3b7617ef4e1f0db9b544b05#wechat_redirect"
            
        }
		
    ]
}';
 

echo createMenu($data,$access_token);//创建菜单
?>